import uiautomator2 as u2
from Python_Uiautomator_Auto.utils.logger import logger

class DeviceManager:
    def __init__(self, serial=None):
        self.d = u2.connect(serial)
        logger.info(f"设备 {serial or 'default'} 已连接")

    def launch_app(self, package):
        self.d.app_start(package)

    def close_app(self, package):
        self.d.app_stop(package)

    def get_device(self):
        return self.d
